//
//  GRFMDownloader.h
//  GRFMDownloader_Example
//
//  Created by Guo Rui on 2018/1/11.
//  Copyright © 2018年 GR. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, GRFMDownloaderState) {
    GRFMDownloaderStateUnKnow,
    GRFMDownloaderStatePause,
    GRFMDownloaderStateDownloading,
    GRFMDownloaderStateDownloadSuccess,
    GRFMDownloaderStateDownloadFailed,
};

typedef void(^DownloadInfoBlock)(long long totalSize);
typedef void(^DownloadProgressChangeBlock)(NSURL *url,float progress);
typedef void(^DownloadStateChangeBlock)(GRFMDownloaderState state);
typedef void(^DownloadSuccessBlock)(NSURL *url, NSString *cachePath);
typedef void(^DownloadFailedBlock)();

@interface GRFMDownloader : NSObject

@property (assign, nonatomic, readonly) GRFMDownloaderState state;
@property (assign, nonatomic, readonly) float progress;

- (void)download:(NSURL *)url
            info:(DownloadInfoBlock)info
  progressChange:(DownloadProgressChangeBlock)progressChange
     stateChange:(DownloadStateChangeBlock)stateChange
         success:(DownloadSuccessBlock)success
           faile:(DownloadFailedBlock)faile;

- (void)download:(NSURL *)url;

- (void)pause;
- (void)resume;
- (void)cancel;
- (void)cancelAndClear;

@end
